home *** CD-ROM | disk | FTP | other *** search
- // AlertTest.c
- /*
- © Copyright 1987 Consulair Corp, All Rights Reserved.
-
- This example shows how to do alerts and dialogs
- All dialogs and alerts for this application are in the file
- "Alert Dialog Resources" in this folder, and were created with
- ResEdit, the resource editor. You may use ResEdit to examine
- the "Alert Dialog Resources" file. The alertTest.link
- file shows how to include the appropriate resources.
- */
-
- #include <stdio.h>
- #include <macdefs.h>
- #include <quickdraw.h>
- #include <textedit.h>
- #include <dialog.h>
-
- #define AlertNumber 129
- #define DialogNumber 130
- #define OKNumber 131
- #define CancelledNumber 132
-
- #define okButton 1
- #define cancelButton 2
- #define TextItem 4
-
- main()
- {
- short itemHit, itemNo, itemType;
- Handle itemHandle;
- DialogPtr dialog;
- Rect rect;
- Str255 text;
-
- // First initialize
- TEInit();
- InitDialogs(0);
-
-
- // Now do an Alert
- ParamText("\pThis is an Alert", "\p", "\p", "\p");
- Alert(AlertNumber, 0);
-
- // And now some Dialogs
- if ((dialog = GetNewDialog(DialogNumber, 0, -1)) != 0)
- {
- itemHit = 0;
- InitCursor();
- while (((itemHit != okButton) && (itemHit != cancelButton)))
- ModalDialog(0, &itemHit);
- if (itemHit == okButton)
- {
- GetDItem(dialog, TextItem, &itemType, &itemHandle, &rect);
- GetIText(itemHandle, &text);
- messageDialog(OKNumber, &text);
- }
- else messageDialog(CancelledNumber, 0);
- DisposeDialog(dialog);
- }
- else noDialog(DialogNumber);
- }
-
- messageDialog(item, text)
- short item;
- Str255 *text;
- {
- DialogPtr dialog;
- short itemHit;
- SysBeep(3);
- if ((dialog = GetNewDialog(item, 0, -1)) != 0)
- {
- InitCursor();
- if (!text) (char *)text = "\p";
- ParamText(text, "\p", "\p", "\p");
- ModalDialog(0, &itemHit);
- DisposeDialog(dialog);
- }
- else noDialog(item);
- }
-
- noDialog(item)
- short item;
- {
- printf("\rCould Not Find Dialog #%d", item);
- getchar();
- }
-